{{ define "main" }}
<section class="section container-fluid mt-n3 pb-3">
  <div class="row justify-content-center">
    <div class="text-center mb-4">
      <img src="/img/gopher.svg" alt="Logo" style="width: 220px" />
    </div>
    <div class="col-lg-12 text-center">
      <h1>{{ .Title }}</h1>
    </div>
    <div class="col-lg-9 col-xl-8 text-center">
      <p class="lead">{{ .Params.lead | safeHTML }}</p>
      <a class="btn btn-primary btn-cta rounded-pill btn-lg m-3" href="/learn/" role="button">
        Get Started
      </a>
      <a class="btn btn-outline-primary btn-cta rounded-pill btn-lg my-3" href="https://github.com/ThreeDotsLabs/watermill" role="button">
        See on GitHub
      </a>
      {{ .Content }}
    </div>
  </div>
</section>

<section class="section py-5 homepage-features">
  <div class="container">
    <!-- EventBus Section -->
    <div class="row justify-content-center mb-5 pb-5 homepage-section-gradient">
      <div class="col-lg-11 col-xl-10 text-center">
        <h2 class="display-4 fw-bold mb-4 gradient-text-1">Publish Events</h2>
        <p class="lead text-muted mb-5">Work with Go structs.<br/>
            Decouple your services with asynchronous processing.
        </p>

          <div class="expressive-code homepage-code-block">
              <figure class="frame not-content">
{{ highlight `event := UserRegistered{
    UserID:   id,
    Email:    email,
    JoinedAt: time.Now(),
}

err := eventBus.Publish(ctx, event)` "go" "" }}
              </figure>
          </div>
      </div>
    </div>

    <!-- EventProcessor Section -->
    <div class="row justify-content-center mb-5 pb-5 homepage-section-gradient">
      <div class="col-lg-11 col-xl-10 text-center">
        <h2 class="display-4 fw-bold mb-4 gradient-text-1">Handle Events</h2>
        <p class="lead text-muted mb-5">Focus on the business logic.<br/>
            Watermill handles routing, serialization and low-level details.
        </p>

          <div class="expressive-code homepage-code-block">
              <figure class="frame not-content">
{{ highlight `eventProcessor.AddHandlers(
    cqrs.NewEventHandler("SendWelcomeEmail", sendWelcomeEmail),
)

func sendWelcomeEmail(ctx context.Context, event *UserRegistered) error {
    return emailService.Send(event.Email, "Welcome!")
}` "go" "" }}
              </figure>
          </div>
      </div>
    </div>

    <!-- Router Middleware Section -->
    <div class="row justify-content-center mb-5 pb-5 homepage-section-gradient">
      <div class="col-lg-11 col-xl-10 text-center">
        <h2 class="display-4 fw-bold mb-4 gradient-text-1">Simple API you already know</h2>
        <p class="lead text-muted mb-5">Use the familiar concepts, similar to an HTTP Router with support for middleware.</p>
          <div class="expressive-code homepage-code-block">
              <figure class="frame not-content">
{{ highlight `router.AddMiddleware(
    middleware.Recoverer,
    middleware.CorrelationID,
    middleware.Timeout(30 * time.Second),
)` "go" "" }}
              </figure>
          </div>
      </div>
    </div>

    <!-- Pub/Sub Support Section -->
    <div class="row justify-content-center pb-5 homepage-section-gradient">
      <div class="col-lg-11 col-xl-10 text-center">
        <h2 class="display-4 fw-bold mb-4 gradient-text-1">Use your favorite Pub/Sub</h2>
        <p class="lead text-muted mb-5">Work with Kafka, RabbitMQ, PostgreSQL, Redis, and more Pub/Subs with the same API. Switch providers without changing your application code.</p>

        <!-- Pub/Sub Logos Collage -->
        <div class="pubsub-logos-container mb-5">
          <div class="pubsub-logos-grid">
              <a href="/pubsubs/aws/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/aws.png" alt="AWS SQS/SNS" />
                  <span>AWS SNS/SQS</span>
              </a>
              <a href="/pubsubs/bolt/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/bolt.png" alt="BoltDB" />
                  <span>BoltDB</span>
              </a>
              <a href="/pubsubs/firestore/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/firestore.png" alt="Google Firestore" />
                  <span>Firestore</span>
              </a>
              <a href="/pubsubs/gochannel/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/gochannel.png" alt="Go Channel" />
                  <span>Go Channel</span>
              </a>
              <a href="/pubsubs/googlecloud/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/gcp.png" alt="Google Cloud Pub/Sub" />
                  <span>Google Cloud Pub/Sub</span>
              </a>
              <a href="/pubsubs/http/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/http.png" alt="HTTP" />
                  <span>HTTP</span>
              </a>
              <a href="/pubsubs/io/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/io.png" alt="I/O" />
                  <span>I/O</span>
              </a>
              <a href="/pubsubs/kafka/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/kafka.png" alt="Apache Kafka" />
                  <span>Kafka</span>
              </a>
              <a href="/pubsubs/sql/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/mysql.png" alt="MySQL" />
                  <span>MySQL</span>
              </a>
              <a href="/pubsubs/nats/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/nats.png" alt="NATS" />
                  <span>NATS</span>
              </a>
              <a href="/pubsubs/sql/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/postgresql.png" alt="PostgreSQL" />
                  <span>PostgreSQL</span>
              </a>
              <a href="/pubsubs/amqp/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/rabbitmq.png" alt="RabbitMQ" />
                  <span>RabbitMQ</span>
              </a>
              <a href="/pubsubs/redisstream/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/redis.png" alt="Redis" />
                  <span>Redis</span>
              </a>
              <a href="/pubsubs/sqlite/" class="pubsub-logo-item">
                  <img src="/img/pubsub-logos/sqlite.png" alt="SQLite" />
                  <span>SQLite</span>
              </a>
          </div>
        </div>
      </div>
    </div>


      <!-- Library vs Framework Section -->
      <div class="row justify-content-center mb-5 pb-5 homepage-section-gradient">
          <div class="col-md-12 col-lg-11 col-xl-10 text-center">
              <h2 class="display-4 fw-bold mb-4 gradient-text-1">Library ≠ Framework</h2>
              <p class="lead text-muted mb-5">Use any architecture you want. No vendor lock-in.</p>
              <div class="expressive-code homepage-code-block">
                  <figure class="frame not-content">
{{ highlight `func (h *Handler) RegisterUser(w http.ResponseWriter, r *http.Request) {
    user := createUser(r)

    // Your existing business logic
    err := h.userRepo.Save(user)
    if err != nil {
        // ...
    }

    // Publish an event using Watermill
    err := h.eventBus.Publish(r.Context(), &UserRegistered{...})
    // ...
}` "go" "" }}
                  </figure>
              </div>
          </div>
      </div>

      <!-- Get Started Section -->
      <div class="row justify-content-center text-center pt-5 mt-5 homepage-section-gradient">
          <div class="col-lg-11 col-xl-10">
              <img src="/img/gopher.svg" alt="Watermill Logo" style="width: 160px;" class="mb-2" />
              <h2 class="display-5 fw-bold mb-4">Start building</h2>
              <div class="mt-3">
                  <a class="btn btn-primary btn-cta rounded-pill btn-lg" href="/learn/" role="button">
                      Get Started
                  </a>
              </div>
          </div>
      </div>
  </div>
</section>
{{ end }}

{{ define "sidebar-prefooter" }}
  {{ if site.Params.doks.backgroundDots -}}
  <div class="d-flex justify-content-start">
    <div class="bg-dots"></div>
  </div>
  {{ end -}}
{{ end }}

{{ define "sidebar-footer" }}
{{ if site.Params.doks.sectionFooter -}}
<section class="section section-md container-fluid bg-light">
  <div class="row justify-content-center text-center">
    <div class="col-lg-7">
      <h2 class="mt-2">Start building with Doks today</h2>
      <a class="btn btn-primary rounded-pill px-4 my-2" href="/docs/{{ if site.Params.doks.docsVersioning }}{{ site.Params.doks.docsVersion }}/{{ end }}prologue/introduction/" role="button">{{ i18n "get-started" }}</a>
    </div>
  </div>
</section>
{{ end -}}
{{ end }}
